(function(){
	var parseParam = function(config){
		//解析js对象为参数名=参数值方式
		var paramData = "";
		var iterParam = function(obj){
			if(obj.constructor == Object){
				var index = 0;
				for(var i in obj){
					if(index != 0){
						paramData += "&";
					}
					if(obj[i].constructor == Object){
						iterParam(obj[i],i);
					}else {
						var value = obj[i];
						if(value.constructor == Date){//日期转换
							value = mini.formatDate(value,"yyyy-MM-dd HH:mm:ss");
						}
						
						if(arguments.length == 2){
							paramData += arguments[1] + "."+ i + "=" + value;
						}else {
							paramData +=  i + "=" + value;
						}
					}
					index++;
				}
			}
		};
		iterParam(config);
		return paramData;
	};
	
	var parseJson = function(config){
		//解析js对象为参数名:参数值方式
		var paramData = "";
		var iterParamJson = function(obj){
			if(obj.constructor == Object){
				var index = 0;
				for(var i in obj){
					if(index != 0){
						paramData += ",";
					}
					if(obj[i].constructor == Object){
						iterParamJson(obj[i],i);
					}else {
						var value = obj[i];
						if(value.constructor == Date){//日期转换
							value = mini.formatDate(value,"yyyy-MM-dd HH:mm:ss");
						}
						
						if(arguments.length == 2){
							paramData += "\"" + arguments[1] + "."+ i + "\":\"" + value + "\"";
						}else {
							paramData +=  "\"" + i + "\"" + ":" + "\"" + value + "\"";
						}
					}
					index++;
				}
			}
		};
		iterParamJson(config);
		return paramData;
	};
	//对象格式的json对象 {"对象.属性1":"属性值","对象.属性2":"属性值"}
	var getJSONObject = function(config){
		var jsonStr = parseJson(config);
		jsonStr = "{" + jsonStr + "}";
		var jsonObject = eval("(" + jsonStr + ")");
		return jsonObject;
	};
	
	window.myutils = {};
	myutils.parseFormDataToParam = parseParam;
	//form对象解析成JSON字符串
	myutils.parseFormToJsonObject = getJSONObject;
})();